<template>
	<div class="extensionorder">
		<div id="kong">
			<img class="kong-img" src="../../img-shopping/pic@2x.png"/>
			<p class="kong-p">这里没有任何商品呢</p>
			<div @click="zhuye()" class="kong-b"><span class="kong-btn">去首页</span></div>
		</div>
		<div class="shopcard-listBox" v-for="item in extenlist">
			<h3 class="shopcard-title"><i><img src="../../img-shopping/icon_dianpu@3x.png"/></i><span v-text="item.seller_name">店铺名字</span>
				<span class="order-goods-stute" v-if="item.status==11">等待买家付款</span>
				<span v-if="item.status==0" class="order-goods-stute">订单已取消</span>
				<span class="order-goods-stute" v-if="item.status==20">待发货</span>
				<span class="order-goods-stute" v-if="item.status==30">待收货</span>
				<span class="order-goods-stute" v-if="item.status==40">已完成订单</span>
			</h3>
			<ul class="shopcard-list-item-box">
				<li class="shopcard-list-item" v-for="itemlist in item.order_goods">
					<div>
						<router-link :to="{path:'/shopXQ/'+itemlist.goods_id}">
							<img :src="'http://www.ntyouxuan.com/'+itemlist.goods_image"/>
							<div class="shopcard-list-item-xinxi">
								<h3>{{itemlist.goods_name}}</h3>
								<p><span>{{itemlist.specification}}</span>
									<span class="order-tkzt" v-if="itemlist.refund_status&&!(itemlist.refund_status=='SUCCESS')&&!(itemlist.refund_status=='CLOSED')">退款中</span>
									<span class="order-tkzt" v-if="itemlist.refund_status&&itemlist.refund_status=='SUCCESS'">退款成功</span>
									<span class="order-tkzt" v-if="itemlist.refund_status&&itemlist.refund_status=='CLOSED'">退款关闭</span>
								</p>
								<div class="shopcard-item-num">
									<span>￥</span>
									<span>{{itemlist.price_detail[0]+'.'}}</span>
									<span>{{itemlist.price_detail[1]}}</span>
									<p class="shopDd-itemnum">x{{itemlist.quantity}}</p>
								</div>
							</div>	
						</router-link>
					</div>
				</li>	
			</ul>
			<div class="extshouru"><span>预估收入</span><span>￥{{item.dst}}</span></div>
			<div class="extxinxi">
				<p>订单编号：{{item.order_sn}}</p>
				<p>下单时间：{{item.add_time}}</p>
			</div>
		</div>
	</div>
</template>

<script>
	export default{
		name:"extensionorder",
		data(){
			return{
				user:0,
				extenlist:[],
				page:1,
				pagenum:0,
				scrollstatu:true
			}
		},
		created:function(){
			this.user=localStorage.getItem('nt_user');
		},
		methods:{
			ajaxex:function(){
				var self=this;
				$.ajax({
					type:"post",
					url:furl+"index.php?app=ajax_buyer_order&act=get_dst_orders",
					data:{'token':self.user,'page':self.page},
					dataType:'json',
					success:function(res){
						if(res.done){
							for(var i=0;i<res.retval.orders.length;i++){
								res.retval.orders[i].add_time=new Date(Number(res.retval.orders[i].add_time)*1000).Format('yyyy-MM-dd hh:mm:ss');
								self.extenlist.push(res.retval.orders[i]);
							}
							self.pagenum=res.retval.page_info.page_count;
							self.xianshi=res.retval.page_info.item_count;
							if (self.xianshi==0) {
								$("#kong").css("display","block")
								
							}else{
								$("#kong").css("display","none")
								
							}
						}
					}
				});
			},
			zhuye: function(){
				window.location.href='http://www.ntyouxuan.com/newnt/#/';
			},
			scrollajax:function(){
				if(this.scrollstatu){
					if(this.page+1<=this.pagenum){
						var dSH=$(document).scrollTop()
						var dH=$(document).height()
						var wH=$(window).height()
						if((dSH+wH)/dH>0.8){
							this.scrollstatu=false;
							this.page=this.page+1;
							console.log(this.page);
							this.ajaxex();
						}
					}
					
				}
			}
		},
		mounted:function(){
			this.ajaxex();
			var self=this;
			window.addEventListener('scroll',self.scrollajax);
		},
		destroyed:function () {
		    this.scrollstatu = false;
		}
	}
</script>

<style>
	.extensionorder{font-size:0;}
	.extensionorder .shopcard-listBox .order-goods-stute{
		float:right;
		font-size:0.28rem;
		color:#fb9722;
		font-weight:500;
	}
	.extshouru{height:0.76rem;line-height: 0.76rem;border-bottom:1px solid #eee;}
	.extshouru>span:first-child{font-size:0.28rem;color:#2B2B2B;}
	.extshouru>span:last-child{float:right;font-size:0.3rem;color:#EE4846;}
	.extxinxi{padding-bottom: 0.3rem;}
	.extxinxi>p{font-size:0.24rem;line-height: 0.28rem;color:#333;margin-top: 0.2rem;}
	#kong{
		text-align: center;
		margin: 0 auto;
		margin-top: 2.2rem;
	}
	#kong img{
		width: 3.6rem;
		height: 3.2rem;
	}
	#kong .kong-p{
		font-size: 0.32rem;
		color: #999999;
		margin-top: 0.84rem;
	}
	#kong .kong-b{
		width: 1.8rem;
		height: 0.7rem;
		border:1px solid #fb9722;
		margin-left:2.85rem;
		margin-top: 0.44rem;
		border-radius: 0.35rem;
	}
	#kong .kong-btn{
		font-size: 0.33rem;
		color: #fb9722;
		line-height: 0.7rem;
	}
</style>